package ils.domain.issue.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="items")
public class Item
{
    private Integer id;
    private Integer bookId;
    private String barcode;
    private Date purchaseDate;
    private Integer sellerId;
    private Integer homeBranchId;
    private Integer currentBranchId;
    private BigDecimal price;
    private Date lastBorrowed;
    private Shelf shelf;
    private Date issueDate;
    private Date issueExpireDate;
    private String status;

    @Id
    @GeneratedValue(generator="increment")
    @GenericGenerator(name="increment", strategy="increment")
    public Integer getId()
    {
        return id;
    }
    public void setId(Integer id)
    {
        this.id = id;
    }
    public Integer getBookId()
    {
        return bookId;
    }
    public void setBookId(Integer bookId)
    {
        this.bookId = bookId;
    }
    public String getBarcode()
    {
        return barcode;
    }
    public void setBarcode(String barcode)
    {
        this.barcode = barcode;
    }
    public Date getPurchaseDate()
    {
        return purchaseDate;
    }
    public void setPurchaseDate(Date purchaseDate)
    {
        this.purchaseDate = purchaseDate;
    }
    public Integer getSellerId()
    {
        return sellerId;
    }
    public void setSellerId(Integer sellerId)
    {
        this.sellerId = sellerId;
    }

    public BigDecimal getPrice()
    {
        return price;
    }
    public void setPrice(BigDecimal price)
    {
        this.price = price;
    }
    public Date getLastBorrowed()
    {
        return lastBorrowed;
    }
    public void setLastBorrowed(Date lastBorrowed)
    {
        this.lastBorrowed = lastBorrowed;
    }
    @ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
    @JoinColumn(name="shelfId")
    public Shelf getShelf()
    {
        return shelf;
    }
    public void setShelf(Shelf shelf)
    {
        this.shelf = shelf;
    }
    public Date getIssueDate()
    {
        return issueDate;
    }
    public void setIssueDate(Date issueDate)
    {
        this.issueDate = issueDate;
    }
    public Date getIssueExpireDate()
    {
        return issueExpireDate;
    }
    public void setIssueExpireDate(Date issueExpireDate)
    {
        this.issueExpireDate = issueExpireDate;
    }

    public Integer getHomeBranchId() {
        return homeBranchId;
    }

    public void setHomeBranchId(Integer homeBranchId) {
        this.homeBranchId = homeBranchId;
    }

    public Integer getCurrentBranchId() {
        return currentBranchId;
    }

    public void setCurrentBranchId(Integer currentBranchId) {
        this.currentBranchId = currentBranchId;
    }

    @Column(columnDefinition = "char")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
